{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "6106c67c-10ad-4895-bcf2-826c593e5642",
   "metadata": {},
   "outputs": [],
   "source": [
    "import polars as pl\n",
    "from perspective.widget import PerspectiveWidget"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8b312d15-4ae7-4f8a-98de-ad6e67c4edc1",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1 = pl.read_parquet(\"new_share.parquet\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e140f59a-bd61-43a6-a609-79b2a48726a0",
   "metadata": {},
   "outputs": [],
   "source": [
    "d2 = pl.read_parquet(\"stock_basic.parquet\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "8c0f56f3-a3bb-460b-afa6-4b05ea2a94eb",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1 = d1.with_columns(\n",
    "    ipo_date=pl.col.ipo_date.str.to_date(\"%Y%m%d\"),\n",
    "    issue_date=pl.col.issue_date.str.to_date(\"%Y%m%d\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "93112d92-602e-44d8-951a-5413de3d3264",
   "metadata": {},
   "outputs": [],
   "source": [
    "d2 = d2.with_columns(\n",
    "    list_date=pl.col.list_date.str.to_date(\"%Y%m%d\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "048ecb51-25cf-4e6a-91c4-95d612507dbc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "7532410992e34fdc9767d900609081b9",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "PerspectiveWidget(binding_mode='server', columns=['ts_code', 'sub_code', 'name', 'ipo_date', 'issue_date', 'am…"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "PerspectiveWidget(d1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "2153fb73-927c-4383-917e-9c95019b4fd3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "bda712c0c65847b7b6e45651645905b5",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "PerspectiveWidget(binding_mode='server', columns=['ts_code', 'symbol', 'name', 'area', 'industry', 'fullname',…"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "PerspectiveWidget(d2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "b56e1b59-256b-4509-8f4c-c5afc2f34fb1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (2_000, 28)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>ts_code</th><th>sub_code</th><th>name</th><th>ipo_date</th><th>issue_date</th><th>amount</th><th>market_amount</th><th>price</th><th>pe</th><th>limit_amount</th><th>funds</th><th>ballot</th><th>symbol</th><th>name_right</th><th>area</th><th>industry</th><th>fullname</th><th>enname</th><th>cnspell</th><th>market</th><th>exchange</th><th>curr_type</th><th>list_status</th><th>list_date</th><th>delist_date</th><th>is_hs</th><th>act_name</th><th>act_ent_type</th></tr><tr><td>str</td><td>str</td><td>str</td><td>date</td><td>date</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>date</td><td>null</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;001390.SZ&quot;</td><td>&quot;001390&quot;</td><td>&quot;古麒绒材&quot;</td><td>2025-05-19</td><td>null</td><td>5000.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>2.0</td><td>0.0</td><td>0.0</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&quot;603014.SH&quot;</td><td>&quot;732014&quot;</td><td>&quot;威高血净&quot;</td><td>2025-05-08</td><td>null</td><td>4114.0</td><td>2685.0</td><td>26.5</td><td>24.82</td><td>1.1</td><td>10.902</td><td>0.03</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&quot;301595.SZ&quot;</td><td>&quot;301595&quot;</td><td>&quot;太力科技&quot;</td><td>2025-05-08</td><td>null</td><td>2707.0</td><td>1178.0</td><td>17.05</td><td>21.55</td><td>0.65</td><td>4.615</td><td>0.02</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&quot;688755.SH&quot;</td><td>&quot;787755&quot;</td><td>&quot;汉邦科技&quot;</td><td>2025-05-07</td><td>null</td><td>2200.0</td><td>704.0</td><td>22.77</td><td>26.35</td><td>0.5</td><td>5.009</td><td>0.03</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&quot;301636.SZ&quot;</td><td>&quot;301636&quot;</td><td>&quot;泽润新能&quot;</td><td>2025-04-28</td><td>null</td><td>1597.0</td><td>774.0</td><td>33.06</td><td>17.57</td><td>0.45</td><td>5.279</td><td>0.02</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;300776.SZ&quot;</td><td>&quot;300776&quot;</td><td>&quot;帝尔激光&quot;</td><td>2019-05-07</td><td>2019-05-17</td><td>1654.0</td><td>1654.0</td><td>57.71</td><td>22.99</td><td>1.6</td><td>9.543</td><td>0.01</td><td>&quot;300776&quot;</td><td>&quot;帝尔激光&quot;</td><td>&quot;湖北&quot;</td><td>&quot;专用机械&quot;</td><td>&quot;武汉帝尔激光科技股份有限公司&quot;</td><td>&quot;Wuhan Dr Laser Technology Corp…</td><td>&quot;dejg&quot;</td><td>&quot;创业板&quot;</td><td>&quot;SZSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>2019-05-17</td><td>null</td><td>&quot;S&quot;</td><td>null</td><td>null</td></tr><tr><td>&quot;300777.SZ&quot;</td><td>&quot;300777&quot;</td><td>&quot;中简科技&quot;</td><td>2019-05-06</td><td>2019-05-16</td><td>4001.0</td><td>3601.0</td><td>6.06</td><td>22.98</td><td>1.1</td><td>2.425</td><td>0.04</td><td>&quot;300777&quot;</td><td>&quot;中简科技&quot;</td><td>&quot;江苏&quot;</td><td>&quot;化纤&quot;</td><td>&quot;中简科技股份有限公司&quot;</td><td>&quot;Sinofibers Technology Co.,Ltd.&quot;</td><td>&quot;zjkj&quot;</td><td>&quot;创业板&quot;</td><td>&quot;SZSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>2019-05-16</td><td>null</td><td>&quot;S&quot;</td><td>null</td><td>null</td></tr><tr><td>&quot;603267.SH&quot;</td><td>&quot;732267&quot;</td><td>&quot;鸿远电子&quot;</td><td>2019-04-30</td><td>2019-05-15</td><td>4134.0</td><td>3721.0</td><td>20.24</td><td>16.5</td><td>1.6</td><td>8.367</td><td>0.03</td><td>&quot;603267&quot;</td><td>&quot;鸿远电子&quot;</td><td>&quot;北京&quot;</td><td>&quot;元器件&quot;</td><td>&quot;北京元六鸿远电子科技股份有限公司&quot;</td><td>&quot;Beijing Yuanliu Hongyuan Elect…</td><td>&quot;hydz&quot;</td><td>&quot;主板&quot;</td><td>&quot;SSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>2019-05-15</td><td>null</td><td>&quot;H&quot;</td><td>null</td><td>null</td></tr><tr><td>&quot;600989.SH&quot;</td><td>&quot;730989&quot;</td><td>&quot;宝丰能源&quot;</td><td>2019-04-30</td><td>2019-05-16</td><td>73336.0</td><td>66002.0</td><td>11.12</td><td>22.07</td><td>22.0</td><td>81.55</td><td>0.25</td><td>&quot;600989&quot;</td><td>&quot;宝丰能源&quot;</td><td>&quot;宁夏&quot;</td><td>&quot;化工原料&quot;</td><td>&quot;宁夏宝丰能源集团股份有限公司&quot;</td><td>&quot;Ningxia Baofeng Energy Group C…</td><td>&quot;bfny&quot;</td><td>&quot;主板&quot;</td><td>&quot;SSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>2019-05-16</td><td>null</td><td>&quot;H&quot;</td><td>null</td><td>null</td></tr><tr><td>&quot;300778.SZ&quot;</td><td>&quot;300778&quot;</td><td>&quot;新城市&quot;</td><td>2019-04-25</td><td>2019-05-10</td><td>2000.0</td><td>2000.0</td><td>27.33</td><td>22.99</td><td>2.0</td><td>5.466</td><td>0.02</td><td>&quot;300778&quot;</td><td>&quot;新城市&quot;</td><td>&quot;深圳&quot;</td><td>&quot;建筑工程&quot;</td><td>&quot;深圳市新城市规划建筑设计股份有限公司&quot;</td><td>&quot;Shenzhen New Land Tool Plannin…</td><td>&quot;xcs&quot;</td><td>&quot;创业板&quot;</td><td>&quot;SZSE&quot;</td><td>&quot;CNY&quot;</td><td>&quot;L&quot;</td><td>2019-05-10</td><td>null</td><td>&quot;N&quot;</td><td>null</td><td>null</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (2_000, 28)\n",
       "┌───────────┬──────────┬──────────┬────────────┬───┬─────────────┬───────┬──────────┬──────────────┐\n",
       "│ ts_code   ┆ sub_code ┆ name     ┆ ipo_date   ┆ … ┆ delist_date ┆ is_hs ┆ act_name ┆ act_ent_type │\n",
       "│ ---       ┆ ---      ┆ ---      ┆ ---        ┆   ┆ ---         ┆ ---   ┆ ---      ┆ ---          │\n",
       "│ str       ┆ str      ┆ str      ┆ date       ┆   ┆ null        ┆ str   ┆ str      ┆ str          │\n",
       "╞═══════════╪══════════╪══════════╪════════════╪═══╪═════════════╪═══════╪══════════╪══════════════╡\n",
       "│ 001390.SZ ┆ 001390   ┆ 古麒绒材 ┆ 2025-05-19 ┆ … ┆ null        ┆ null  ┆ null     ┆ null         │\n",
       "│ 603014.SH ┆ 732014   ┆ 威高血净 ┆ 2025-05-08 ┆ … ┆ null        ┆ null  ┆ null     ┆ null         │\n",
       "│ 301595.SZ ┆ 301595   ┆ 太力科技 ┆ 2025-05-08 ┆ … ┆ null        ┆ null  ┆ null     ┆ null         │\n",
       "│ 688755.SH ┆ 787755   ┆ 汉邦科技 ┆ 2025-05-07 ┆ … ┆ null        ┆ null  ┆ null     ┆ null         │\n",
       "│ 301636.SZ ┆ 301636   ┆ 泽润新能 ┆ 2025-04-28 ┆ … ┆ null        ┆ null  ┆ null     ┆ null         │\n",
       "│ …         ┆ …        ┆ …        ┆ …          ┆ … ┆ …           ┆ …     ┆ …        ┆ …            │\n",
       "│ 300776.SZ ┆ 300776   ┆ 帝尔激光 ┆ 2019-05-07 ┆ … ┆ null        ┆ S     ┆ null     ┆ null         │\n",
       "│ 300777.SZ ┆ 300777   ┆ 中简科技 ┆ 2019-05-06 ┆ … ┆ null        ┆ S     ┆ null     ┆ null         │\n",
       "│ 603267.SH ┆ 732267   ┆ 鸿远电子 ┆ 2019-04-30 ┆ … ┆ null        ┆ H     ┆ null     ┆ null         │\n",
       "│ 600989.SH ┆ 730989   ┆ 宝丰能源 ┆ 2019-04-30 ┆ … ┆ null        ┆ H     ┆ null     ┆ null         │\n",
       "│ 300778.SZ ┆ 300778   ┆ 新城市   ┆ 2019-04-25 ┆ … ┆ null        ┆ N     ┆ null     ┆ null         │\n",
       "└───────────┴──────────┴──────────┴────────────┴───┴─────────────┴───────┴──────────┴──────────────┘"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = d1.join(d2, on=\"ts_code\", how=\"left\")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "117a805a-e885-4735-82a9-bca6473c7835",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "5922f19e855741d0938c51c8fe02fec4",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "PerspectiveWidget(binding_mode='server', columns=['ts_code', 'sub_code', 'name', 'ipo_date', 'issue_date', 'am…"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "PerspectiveWidget(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "5426c699-67f8-418e-8b29-aa45de7556c1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "05d881acf789420cab2017996555dcc0",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "PerspectiveWidget(binding_mode='server', columns=['ts_code', 'sub_code', 'name', 'ipo_date', 'issue_date', 'am…"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "PerspectiveWidget(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "21c44f8f-0890-46f7-a8d4-baf562c13ad1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "78175cb4e22e4dbcbe5c6469cfc3c2e1",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "PerspectiveWidget(binding_mode='server', columns=['ts_code', 'sub_code', 'name', 'ipo_date', 'issue_date', 'am…"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "PerspectiveWidget(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "09790f40-8fa9-4d79-ab31-858e92438ede",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "bcd49a07fe614f8baf3fda59745663e3",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "PerspectiveWidget(binding_mode='server', columns=['ts_code', 'sub_code', 'name', 'ipo_date', 'issue_date', 'am…"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "PerspectiveWidget(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "08f9da05-68f2-4746-9067-31c279b3441c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "d47a3387de4a4f5794965c70f618d58b",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "PerspectiveWidget(binding_mode='server', columns=['ts_code', 'sub_code', 'name', 'ipo_date', 'issue_date', 'am…"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "PerspectiveWidget(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0b23acb5-ac6b-4e2c-b251-399143896387",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
